package com.example.demotest.repository;

import com.example.demotest.pojo.ChatMessage;
import com.example.demotest.pojo.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ChatMessageRepository extends CrudRepository<ChatMessage, Long> {

    List<ChatMessage> findBySenderAndReceiverOrderByTimestampAsc(User sender, User receiver);

    List<ChatMessage> findByReceiverAndIsReadFalse(User receiver);
}